home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / libs / pdcurs21 / private / _scr2win.c < prev    next >
C/C++ Source or Header  |  1993-08-13  |  3KB  |  104 lines

  1. #define    CURSES_LIBRARY    1
  2. #include <curses.h>
  3.  
  4. #ifndef    NDEBUG
  5. char *rcsid__scr2win = "$Header: k:/tools/src/curses/private/rcs/_scr2win.c 2.1.0.2 93/08/13 10:54:57 frotz Beta2 $";
  6. #endif
  7.  
  8.  
  9.  
  10.  
  11. /*man-start*********************************************************************
  12.  
  13.   PDC_cpy_scrn2win()    - Copies current screen contents to a window.
  14.  
  15.   PDCurses Description:
  16.       This routine will copy the current contents of the screen (assuming
  17.     that this functionality is available) into the passed window.  This
  18.     routine will be called from within initscr() and the private window
  19.     containing the original screen contents will be displayed just prior
  20.     to termination in endwin().
  21.  
  22.     This routine makes use of PDC_get_char_and_attr() and PDC_gotoxy()
  23.     to collect the contents of the screen.
  24.  
  25.     This routine enables color if it is available by calling start_color().
  26.  
  27.     WARNING: This routine uses COLOR_PAIRS-2 as the color
  28.     pair number.
  29.  
  30.   PDCurses Return Value:
  31.      This function returns OK on success, otherwise an ERR is returned.
  32.  
  33.   PDCurses Errors:
  34.     *    operation is unsupported by current platform.
  35.  
  36.     *    passed window is smaller than current screen size
  37.         though as much of the screen contents are copied to the
  38.         window as possible.
  39.  
  40.     *    passing a NULL window pointer.
  41.  
  42.   Portability:
  43.      PDCurses    int    PDC_cpy_scrn2win( WINDOW* w );
  44.  
  45. **man-end**********************************************************************/
  46.  
  47. int    PDC_cpy_scrn2win( WINDOW *w )
  48. {
  49. #ifdef    FLEXOS
  50.     return( ERR );
  51. #endif
  52. #ifdef    OS2
  53.     return( ERR )    /* Force an error until an OS/2 developer can verify */
  54. #endif
  55. #ifdef    DOS
  56.     int    lines;
  57.     int    cols;
  58.     chtype    ch;
  59.     chtype    bold;
  60.     chtype    blinking;
  61.     int    foreground;
  62.     int    background;    
  63.     int    x;
  64.     int    y;
  65.     bool    visible    = _cursvar.visible_cursor;
  66.     bool    mono    = _cursvar.mono;
  67.  
  68.     if  (!mono)
  69.         start_color();
  70.  
  71.     if  (visible)
  72.         cursoff();
  73.     PDC_get_cursor_pos( &y, &x );
  74.  
  75.     /*
  76.     *    Sorry, only monochrome coloring
  77.     *    The color at (row,col) is it.
  78.     */
  79.     ch = (chtype)PDC_get_char_and_attr();
  80.     foreground = ((ch >> (8+0)) & 0x000F);
  81.     background = ((ch >> (8+4)) & 0x000F);
  82.     init_pair( COLOR_PAIRS-2, foreground, background );
  83.  
  84.     werase( w );
  85.     for( lines=0; (lines < LINES && lines < w->_maxy); lines++ )
  86.     {
  87.         for( cols=0; (cols < COLS && cols < w->_maxx); cols++ )
  88.         {
  89.             PDC_gotoxy( lines, cols );
  90.             ch = (chtype)PDC_get_char_and_attr();
  91.             ch &= A_CHARTEXT;
  92.             mvwaddch( w, lines, cols, ch );
  93.         }
  94.     }
  95.     wmove( w, y, x );
  96.     if  (visible)
  97.     {
  98.         curson();
  99.         mvcur( LINES, COLS, y, x );
  100.     }
  101.     return( OK );
  102. #endif
  103. }
  104.